package pDatenbank_Zugriff;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MySQLAccess {
	private static MySQLAccess instance = new MySQLAccess();

	public static final String URL = "jdbc:mysql://localhost/cocktaildb";
	public static final String USER = "root";
	public static final String PASSWORD = "";

	private MySQLAccess() {
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private Connection createConnection() {
		Connection connection = null;
		try {
			connection = DriverManager.getConnection(URL, USER, PASSWORD);
		} catch (SQLException e) {
			System.out.println("ERROR: Unable to Connect to Database");
		}
		return connection;
	}

	public static Connection getConnection() {
		return instance.createConnection();
	}

}